package com.es.util.db;

public class DaoUtil {

	public static String[] getOrder(String sql){
		sql = sql.toLowerCase();
		if(sql.indexOf("order")<=0)
			return new String[]{sql.substring(sql.indexOf("select")+6,sql.length()),
								"order by 1",
								"desc",
								"asc"};
		else{
			sql  = sql.substring(sql.indexOf("order"),sql.length());
			if(sql.indexOf("desc")>0)
				return new String[]{sql.substring(sql.indexOf("select")+6,sql.indexOf("order")),
									sql.substring(sql.indexOf("order"),sql.indexOf("desc")),
									"desc",
									"asc"};
			else 
				return new String[]{sql.substring(sql.indexOf("select")+6,sql.indexOf("order")),
									sql.substring(sql.indexOf("order"),sql.indexOf("asc")),
									"asc",
									"desc"};
		}
	}
}
